<div class="row">
  <div class="col-md-6 col-md-offset-3">

    <%= form_with(model: article, local: true) do |f| %>
      <% if article.errors.any? %>
        <div id="error_explanation">
          <ul>
            <% article.errors.full_messages.each do |message| %>
              <li><%= message %></li>
            <% end %>
          </ul>
        </div>
      <% end %>

      <div class="field">
        <%= f.label :title, '标题' %>
        <%= f.text_field :title, class: 'form-control' %>
      </div>

      <div class="field">
        <%= f.label :category_id, '标签' %>
        <%= f.collection_select :category_id, Category.all, :id, :name, { prompt: "选择一个分类"} %>

        <%= link_to  "新建分类",  new_category_path, remote: true %>
      </div>

      <div class="field">
        <%= f.label :content, "文章内容" %>
        <%= f.text_area :content, class: "ckeditor" %>
      </div>


      <div class="actions">
        <%= f.submit "保存文章", class: 'btn btn-info' %>
      </div>
    <% end %>
  </div>
</div>
